package org.gw.building.repositories;

import org.gw.building.model.ClassInfo;
import org.gw.building.model.Term;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface ClassInfoRepository extends CrudRepository<ClassInfo, String> {
	@Query("from ClassInfo c where (?1 is null or c.term.id=?1)")
	public List<ClassInfo> getAllByTerm(String term);

	public ClassInfo getBybjCodeAndTerm(String bjCode, Term term);

	public ClassInfo getBybjNameAndTerm(String bjName, Term term);

	@Transactional
	public int deleteBybjCodeGreaterThanAndTerm(String bjCode, Term term);
}
